#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>

int main()
{
	int i, n, x, l, b, d, o, j;
	char a[100000];
	scanf("%d", &n);
	getchar();
	for (i = 0; i < n; i++) {
		gets(a);
		x = strlen(a);
		l = b = d = o = 0;
		for (j = 0; j < x; j++) {
			if ((a[j] >= 'a' && a[j] <= 'z') || (a[j] >= 'A' && a[j] <= 'Z')) l++;
			else if (a[j] == ' ') b++;
			else if (a[j] >= '0' && a[j] <= '9') d++;
			else o++;
		}
		printf("letter=%d,blank=%d,digit=%d,other=%d\n", l, b, d, o);
	}

	return 0;
}
//1087